import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.Arrays;

public class meiju {

    public static void main(String[] args) {
        System.out.println(Arrays.toString(color.values()));
        color.p();
        switch (color.RED) {
            case RED -> System.out.println("red");
            case BLUE -> System.out.println("blue");
            case WRITE -> System.out.println("write");
        }

        /**
        //0 = su -> print(星期天)
        //std(int i){
        //i = su
//        print(星期天)
        // }
         *
         */

        //su -> 星期天
        //print(su)
        System.out.println('q');
        System.out.println(color.BLACK.ordinal());
        System.out.println(color.RED.ordinal());
        System.out.println(color.BLACK.compareTo(color.RED));//返回俩个枚举在定义时的顺序 BLACK - RED
        System.out.println('a');
//        color.main(new String[]{"aa","aaa"});
    }
}

enum color {
    RED(1) , BLUE(2), BLACK(3),WRITE(4);

    private color(int i) {
    }
    public static void p() {
        System.out.println("p");
    }

    public static void main(String[] args) {

        //枚举的构造方法是private修饰的且不能被反射
        try {
            Class<?> c = Class.forName("color");
            //子类要重写父类的构造方法
            Modifier.classModifiers();
            Constructor<color> constructor = (Constructor<color>) c.getDeclaredConstructor(String.class, int.class);
            constructor.setAccessible(true);
            color aa = constructor.newInstance("ee", 1);//在newInstance中 Modifier.ENUM能过滤掉枚举所以不嫩反射枚举
            System.out.println("dedao" + aa);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }

    }
    public static void maine(String[] args) {
        System.out.println(Arrays.toString(args));
        color[] c = color.values();//将枚举类型成员以数组形式返回
        System.out.println(c[0].ordinal());
        color a = color.valueOf("WRITE");
        System.out.println(a.ordinal() + " " + a.name());
        color color1 = color.BLACK;
        switch (color1) {

        }
    }
}


